<template>
  <div>
    <el-form ref="form" :model="formData">
      <el-form-item prop="aa">
        <el-input size="small" v-model="formData.aa" placeholder="aa" clearable></el-input>
      </el-form-item>
      <el-form-item prop="bb">
        <el-input size="small" v-model="formData.bb" placeholder="bb" clearable></el-input>
      </el-form-item>
      <el-form-item prop="cc">
        <el-input size="small" v-model="formData.cc" placeholder="cc" clearable></el-input>
      </el-form-item>
      <el-button type="primary" @click="submit">提交</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formData: {
        aa: '',
        bb: '',
        cc: ''
      }
    };
  },
  methods: {
    async submit() {
      const aa = new Promise((resolve, reject) => {
        if (this.formData.aa) {
          resolve()
        } else {
          this.$confirm("aa 未填写", '提示', {
            confirmButtonText: '确认',
            cancelButtonText: '取消'
          }).then(() => {
            resolve();
          }).catch(() => {
            reject("aa is null");
          })
        }
      });
      const bb = new Promise((resolve, reject) => {
        if (this.formData.bb) {
          resolve();
        } else {
          reject("bb is null");
        }
      });
      const cc = new Promise((resolve, reject) => {
        if (this.formData.cc) {
          resolve();
        } else {
          reject("cc is null");
        }
      });
      Promise.all([aa, bb, cc])
          .then(() => {
            alert('asdf')
          })
          .catch((err) => {
            console.log(err)
          })
    }
  }
};
</script>